<div class="content-section introduction">
    <div>
        <span class="feature-title">Paginator</span>
        <span>Paginator is a generic widget to display content in paged format.</span>
    </div>
</div>

<div class="content-section implementation">
    <p-paginator rows="10" totalRecords="120" [rowsPerPageOptions]="[10,20,30]"></p-paginator>
</div>

<div class="content-section documentation">
    <p-tabView effect="fade">
        <p-tabPanel header="Documentation">
            <h3>Import</h3>
<pre>
<code class="language-typescript" pCode ngNonBindable>
import &#123;PaginatorModule&#125; from 'primeng/primeng';
</code>
</pre>

            <h3>Getting Started</h3>
            <p>Paginator is defined using p-paginator element.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-paginator&gt;&lt;/p-paginator&gt;
</code>
</pre>
            <h3>Rows and TotalRecords</h3>
            <p>Rows and TotalRecords define how many pages the paginator should display. Paginator below will have 10 pages.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-paginator rows="10" totalRecords="100"&gt;&lt;/p-paginator&gt;
</code>
</pre>

            <h3>PageLinks</h3>
            <p>PageLinks provide shortcuts to jump to a specific page, use pageLinkSize property to define the number of links to display. Default is 5.</p>

<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-paginator rows="10" totalRecords="100" pageLinkSize="3"&gt;&lt;/p-paginator&gt;
</code>
</pre>

            <h3>Rows Per Page</h3>
            <p>Number of items per page can be changed by the user using a dropdown if you define rowsPerPageOptions as an array of possible values.</p>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-paginator rows="10" totalRecords="120" [rowsPerPageOptions]="[10,20,30]"&gt;&lt;/p-paginator&gt;
</code>
</pre>

            <h3>Properties</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                        <tr>
                            <th>Name</th>
                            <th>Type</th>
                            <th>Default</th>
                            <th>Description</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>totalRecords</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Number of total records.</td>
                        </tr>
                        <tr>
                            <td>rows</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Data count to display per page.</td>
                        </tr>
                        <tr>
                            <td>first</td>
                            <td>number</td>
                            <td>0</td>
                            <td>Zero-relative number of the first row to be displayed.</td>
                        </tr>
                        <tr>
                            <td>pageLinkSize</td>
                            <td>number</td>
                            <td>5</td>
                            <td>Number of page links to display.</td>
                        </tr>
                        <tr>
                            <td>rowsPerPageOptions</td>
                            <td>array</td>
                            <td>null</td>
                            <td>Array of integer values to display inside rows per page dropdown.</td>
                        </tr>
                        <tr>
                            <td>style</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Inline style of the component.</td>
                        </tr>
                        <tr>
                            <td>styleClass</td>
                            <td>string</td>
                            <td>null</td>
                            <td>Style class of the component.</td>
                        </tr>
                        <tr>
                            <td>alwaysShow</td>
                            <td>boolean</td>
                            <td>true</td>
                            <td>Whether to show it even there is only one page.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Events</h3>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Parameters</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>onPageChange</td>
                            <td>event.first: Index of first record <br>
                                event.rows: Number of rows to display in new page <br>
                                event.page: Index of the new page <br>
                                event.pageCount: Total number of pages <br></td>
                            <td>Callback to invoke when page changes, the event object contains information about the new state.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-paginator rows="10" totalRecords="100" (onPageChange)="paginate($event)"&gt;&lt;/p-paginator&gt;
</code>
</pre>

<pre>
<code class="language-typescript" pCode ngNonBindable>
export class MyComponent &#123;

    paginate(event) &#123;
        //event.first = Index of the first record
        //event.rows = Number of rows to display in new page
        //event.page = Index of the new page
        //event.pageCount = Total number of pages
    &#125;

&#125;
</code>
</pre>

            <h3>Styling</h3>
            <p>Following is the list of structural style classes, for theming classes visit <a href="#" [routerLink]="['/theming']">theming page</a>.</p>
            <div class="doc-tablewrapper">
                <table class="doc-table">
                    <thead>
                    <tr>
                        <th>Name</th>
                        <th>Element</th>
                    </tr>
                    </thead>
                    <tbody>
                        <tr>
                            <td>ui-paginator</td>
                            <td>Container element.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-first</td>
                            <td>First page element.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-prev</td>
                            <td>Previous page element.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-pages</td>
                            <td>Container of page links.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-page</td>
                            <td>A page link.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-next</td>
                            <td>Next page element.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-last</td>
                            <td>Last page element.</td>
                        </tr>
                        <tr>
                            <td>ui-paginator-rpp-options</td>
                            <td>Rows per page dropdown.</td>
                        </tr>
                    </tbody>
                </table>
            </div>

            <h3>Dependencies</h3>
            <p>None.</p>
        </p-tabPanel>

        <p-tabPanel header="Source">
            <a href="https://github.com/primefaces/primeng/tree/master/src/app/showcase/components/paginator" class="btn-viewsource" target="_blank">
                <i class="fa fa-github"></i>
                <span>View on GitHub</span>
            </a>
<pre>
<code class="language-markup" pCode ngNonBindable>
&lt;p-paginator rows="10" totalRecords="120" [rowsPerPageOptions]="[10,20,30]"&gt;&lt;/p-paginator&gt;
</code>
</pre>
        </p-tabPanel>
    </p-tabView>
</div>
